package cn.itsource.rpms.util;

import java.lang.reflect.Field;

public class  CopyBean {


    public static <T> void copyNotNullFiled(T origin,T destination){
        if (origin == null || destination == null) {
            return;
        }
        if (!origin.getClass().equals(destination.getClass())) {
            return;
        }
        Field[] fields = origin.getClass().getDeclaredFields();
        for (int i = 0; i <fields.length ; i++) {
            try {
                fields[i].setAccessible(true);
                Object value = fields[i].get(origin);
                if (null != value) {
                    fields[i].set(destination, value);
                }
                fields[i].setAccessible(false);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }


    }
}
